# 1 super()查找父类 适合于 单继承
# 2 super()如果有2个老爹 

# 2 定义黑马学校类
class HeimaSchool(object):
    def __init__(self):
        self.kongfu = '[AI方法]'

    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')


# 1 定义师父类
class Master(object):
    # 1.1 init
    def __init__(self):
        self.kongfu = '[传统方法]'

    # 1.2 摊煎饼方法 make_cake
    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')


class Prentice(Master, HeimaSchool):
    def __init__(self):
        self.kongfu = '[独创方法]'

    def make_cake(self):
        print(f'使用{self.kongfu}摊煎饼')

    def make_cake_bysuper(self):
        print('--------------super(Prentice, self)---------------')
        super(Prentice, self).__init__()  # Prentice的super 即Master
        super(Prentice, self).make_cake()

        print('--------------super(Master, self)---------------')
        super(Master, self).__init__()  # Master的super 即HeimaSchool
        super(Master, self).make_cake()

        print('--------------super(HeimaSchool, self)---------------')
        # super(HeimaSchool, self).__init__()   # HeimaSchool的super 即 object
        # super(HeimaSchool, self).make_cake()    # AttributeError: 'super' object has no attribute 'make_cake'


# Prentice --> Master--> HeimaSchool --> object

# 3 测试继承
xiaoming = Prentice()
xiaoming.make_cake()

print('-----------------------------')
xiaoming.make_cake_bysuper()

print('-----------------------------')
print(Prentice.__mro__)

# (<class '__main__.Prentice'>,
# <class '__main__.Master'>,
# <class '__main__.HeimaSchool'>,
# <class 'object'>)
